<?php

namespace App\Models\Panx;

use App\Models\Store\HmSkinRecord;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

/**
 * Class BodyPosition
 *
 * @property-read BelongsToMany products
 *
 * @package App\Models\Panx
 * @mixin Builder
 */
class BodyPosition extends Model
{
    protected $table = 'body_positions';
    protected $guarded = [];

    const COMMON = 1; // 通用
    const EYE = 2; // 眼尾
    const CHEEK = 3; // 脸颊
    const NECK = 4; // 颈部
    const HAND = 5; // 手臂

    const HM_POSITION_BODY_POSITION_MAP = [
        HmSkinRecord::POSITION_EYE   => self::EYE,
        HmSkinRecord::POSITION_CHEEK => self::CHEEK,
        HmSkinRecord::POSITION_NECK  => self::NECK,
        HmSkinRecord::POSITION_HAND  => self::HAND,
    ];


    /**
     * @used-by $products
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function products()
    {
        return $this->belongsToMany(Product::class, 'product_pivot_body_position', 'body_position_id', 'product_id');
    }

}
